const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lessonid: '',
  },

  goHistory: function (e) {
    wx.navigateTo({
      url: '../signHistory/signHistory?lessonid=' + this.data.lessonid,
    })
  },

  goWord: function (e) {
    var that = this;
    console.log(that.data.lessonid)
    wx.request({
      url: app.globalData.ServerUrl + 'word/isWordGoing.php',
      data: {
        lessonid: that.data.lessonid
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
        if (res.data == null) {
          wx.navigateTo({
            url: '../signByWord/signByWord?lessonid=' + that.data.lessonid,
          })
        } else {
          if (res.data.state === 'false') {
            wx.navigateTo({
              url: '../signByWord/signByWord?lessonid=' + that.data.lessonid,
            })
          } else {
            wx.redirectTo({
              url: '../signList/signList?lessonid=' + that.data.lessonid + ''
            })
          }
        }
      },
      fail: function (res) {},
      complete: function (res) {},
    })
  },

  goEwm: function (e) {
    var that = this;
    console.log(that.data.lessonid)
    wx.request({
      url: app.globalData.ServerUrl + 'ewm/isEwmGoing.php',
      data: {
        lessonid: that.data.lessonid
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
        if (res.data == null) {
          wx.navigateTo({
            url: '../signByEwm/signByEwm?lessonid=' + that.data.lessonid,
          })
        } else {
          if (res.data.state === 'false') {
            wx.navigateTo({
              url: '../signByEwm/signByEwm?lessonid=' + that.data.lessonid,
            })
          } else {
            wx.navigateTo({
              url: '../signByEwmList/signByEwmList?lessonid=' + that.data.lessonid,
            })
          }
        }
      },
      fail: function (res) {},
      complete: function (res) {},
    })
  },

  goMap: function (e) {
    var that = this;
    console.log(that.data.lessonid)
    wx.request({
      url: app.globalData.ServerUrl + 'map/isMapGoing.php',
      data: {
        lessonid: that.data.lessonid
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
        if (res.data == null) {
          wx.navigateTo({
            url: '../signByMap/signByMap?lessonid=' + that.data.lessonid,
          })
        } else {
          if (res.data.state === 'false') {
            wx.navigateTo({
              url: '../signByMap/signByMap?lessonid=' + that.data.lessonid,
            })
          } else {
            wx.navigateTo({
              url: '../signByMapList/signByMapList?lessonid=' + that.data.lessonid,
            })
          }
        }
      },
      fail: function (res) {},
      complete: function (res) {},
    })
  },

  


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      lessonid: options.lessonid
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})